package com.purebang.spaceinvaders;

import java.awt.Rectangle;

public class BunkerSection {
	
	public static final int BUNKER_SECTION_HEIGHT = 20;
	public static final int BUNKER_SECTION_WIDTH = 20;
	
	private final int DAMAGE_RESISTANCE = 4;
	
	private Rectangle hitbox;
	private int hitsTaken;
	
	public BunkerSection(int x, int y) {
		hitbox = new Rectangle(x, y, BUNKER_SECTION_WIDTH, BUNKER_SECTION_HEIGHT);
		hitsTaken = 0;
	}
	
	public boolean isHit(Projectile p) {
		if (hitbox.intersects(p.getHitbox())) {
			hitsTaken = hitsTaken + p.getPower();
			return true;
		}
		return false;	
	}
	
	public boolean isHit(Laser l) {
		if(hitbox.intersects(l.getHitbox())) {
			hitsTaken++;
			return true;
		}
		return false;
	}
	
	public boolean isDestroyed() {
		if (hitsTaken >= DAMAGE_RESISTANCE) {
			return true;
		}
		return false;
	}
	
	public Rectangle getSectionHitBox() {
		return hitbox;
	}

}
